﻿using System;
using System.Collections.Generic;
using System.IO;
using Terraria.World.Generation;

namespace Terraria.ModLoader
{
	// Token: 0x0200020D RID: 525
	public static class WorldHooks
	{
		// Token: 0x06001708 RID: 5896 RVA: 0x00011921 File Offset: 0x0000FB21
		internal static void Add(ModWorld modWorld)
		{
			WorldHooks.worlds.Add(modWorld);
		}

		// Token: 0x06001709 RID: 5897 RVA: 0x00417458 File Offset: 0x00415658
		internal static void ResizeArrays()
		{
			WorldHooks.NetWorlds = ModLoader.BuildGlobalHook<ModWorld, Action<BinaryWriter>>(WorldHooks.worlds, (ModWorld w) => (Action<BinaryWriter>)Delegate.CreateDelegate(typeof(Action<BinaryWriter>), w, methodof(ModWorld.NetSend(BinaryWriter))));
		}

		// Token: 0x0600170A RID: 5898 RVA: 0x0001192E File Offset: 0x0000FB2E
		internal static void Unload()
		{
			WorldHooks.worlds.Clear();
		}

		// Token: 0x0600170B RID: 5899 RVA: 0x00417504 File Offset: 0x00415704
		internal static void SetupWorld()
		{
			foreach (ModWorld modWorld in WorldHooks.worlds)
			{
				modWorld.Initialize();
			}
		}

		// Token: 0x0600170C RID: 5900 RVA: 0x00417550 File Offset: 0x00415750
		internal static void WriteNetWorldOrder(BinaryWriter w)
		{
			w.Write((short)WorldHooks.NetWorlds.Length);
			foreach (ModWorld modWorld in WorldHooks.NetWorlds)
			{
				w.Write(modWorld.mod.netID);
				w.Write(modWorld.Name);
			}
		}

		// Token: 0x0600170D RID: 5901 RVA: 0x004175A0 File Offset: 0x004157A0
		internal static void ReadNetWorldOrder(BinaryReader r)
		{
			short num = r.ReadInt16();
			WorldHooks.NetWorlds = new ModWorld[(int)num];
			for (short num2 = 0; num2 < num; num2 += 1)
			{
				WorldHooks.NetWorlds[(int)num2] = ModNet.GetMod((int)r.ReadInt16()).GetModWorld(r.ReadString());
			}
		}

		// Token: 0x0600170E RID: 5902 RVA: 0x004175EC File Offset: 0x004157EC
		public static void PreWorldGen()
		{
			foreach (ModWorld modWorld in WorldHooks.worlds)
			{
				modWorld.PreWorldGen();
			}
		}

		// Token: 0x0600170F RID: 5903 RVA: 0x00417638 File Offset: 0x00415838
		public static void ModifyWorldGenTasks(List<GenPass> passes, ref float totalWeight)
		{
			foreach (ModWorld modWorld in WorldHooks.worlds)
			{
				modWorld.ModifyWorldGenTasks(passes, ref totalWeight);
			}
		}

		// Token: 0x06001710 RID: 5904 RVA: 0x00417688 File Offset: 0x00415888
		public static void PostWorldGen()
		{
			foreach (ModWorld modWorld in WorldHooks.worlds)
			{
				modWorld.PostWorldGen();
			}
		}

		// Token: 0x06001711 RID: 5905 RVA: 0x004176D4 File Offset: 0x004158D4
		public static void ResetNearbyTileEffects()
		{
			foreach (ModWorld modWorld in WorldHooks.worlds)
			{
				modWorld.ResetNearbyTileEffects();
			}
		}

		// Token: 0x06001712 RID: 5906 RVA: 0x00417720 File Offset: 0x00415920
		public static void PreUpdate()
		{
			foreach (ModWorld modWorld in WorldHooks.worlds)
			{
				modWorld.PreUpdate();
			}
		}

		// Token: 0x06001713 RID: 5907 RVA: 0x0041776C File Offset: 0x0041596C
		public static void PostUpdate()
		{
			foreach (ModWorld modWorld in WorldHooks.worlds)
			{
				modWorld.PostUpdate();
			}
		}

		// Token: 0x06001714 RID: 5908 RVA: 0x004177B8 File Offset: 0x004159B8
		public static void TileCountsAvailable(int[] tileCounts)
		{
			foreach (ModWorld modWorld in WorldHooks.worlds)
			{
				modWorld.TileCountsAvailable(tileCounts);
			}
		}

		// Token: 0x06001715 RID: 5909 RVA: 0x00417804 File Offset: 0x00415A04
		public static void ChooseWaterStyle(ref int style)
		{
			foreach (ModWorld modWorld in WorldHooks.worlds)
			{
				modWorld.ChooseWaterStyle(ref style);
			}
		}

		// Token: 0x06001716 RID: 5910 RVA: 0x00417850 File Offset: 0x00415A50
		public static void ModifyHardmodeTasks(List<GenPass> passes)
		{
			foreach (ModWorld modWorld in WorldHooks.worlds)
			{
				modWorld.ModifyHardmodeTasks(passes);
			}
		}

		// Token: 0x06001717 RID: 5911 RVA: 0x0041789C File Offset: 0x00415A9C
		public static void PostDrawTiles()
		{
			foreach (ModWorld modWorld in WorldHooks.worlds)
			{
				modWorld.PostDrawTiles();
			}
		}

		// Token: 0x040015DC RID: 5596
		internal static readonly IList<ModWorld> worlds = new List<ModWorld>();

		// Token: 0x040015DD RID: 5597
		internal static ModWorld[] NetWorlds;
	}
}
